package animal;

public class Animaltest {

	public static void main(String[] args) {
	Animal[]animals= {
			new Dog("大黄",3,"金毛"),
			new Cat("小花",2,"白色"),
			new Dog("小黑",4,"拉布拉多")
	};
    for(Animal animal:animals) {
    	System.out.println("名字:"+animal.getName());
    	System.out.println("年龄:"+animal.getAge());
    	animal.makeSound();
    	if(animal instanceof Trainable) {
    		((Trainable)animal).train();
    	}
    	if (animal instanceof Swimmable) {
    		((Swimmable)animal).swim();
    	}
    }
	}

}
